<?php
namespace app\admin\controller;
use think\Db;
use lib\Curl;
class Users extends Base{
    public function users_list(){
        $keyword=input('get.keyword');
        if (!empty(input('get.fromtime'))) {
            $fromtime=strtotime(input('get.fromtime'));
        }else{
            $fromtime=0;
        }
        if (!empty(input('get.totime'))) {
            $totime=strtotime(input('get.totime'))+86400;
        }else{
            $totime=time();
        }
        $map = [
            ['time', '>', $fromtime],
            ['time', '<', $totime]
        ];
        $list=Db::name('users')->where($map)->where('phone','like',"%{$keyword}%")->order('id desc')->paginate(10);
        $lists=Db::name('users')->where($map)->where('phone','like',"%{$keyword}%")->select();
        
        $this->assign('keyword',input('get.keyword'));
        $this->assign('fromtime',input('get.fromtime'));
        $this->assign('totime',input('get.totime'));
        $this->assign('list',$list);
        $this->assign('lists',$lists);
        return $this->fetch();
    }
    public function money_bills()
    {
        $params=input('get.');
        $res=Db::name('money_bill')->where('user_id',$params['id'])->order('id desc')->paginate(10);
        $counts=Db::name('money_bill')->where('user_id',$params['id'])->count();
        $items = $res->items();
        foreach ($items as $key => $value) {
            if($items[$key]['type']==1){
                $items[$key]['des']=Db::name('ordersub')->where('id',$items[$key]['orders_id'])->value('title');
            }elseif($items[$key]['type']==2){
                $items[$key]['des']=Db::name('ordersub')->where('id',$items[$key]['orders_id'])->value('title');
            }elseif($items[$key]['type']==3){
                $items[$key]['des']='提现';
            }
        }
        $this->assign('res',$res);
        $this->assign('counts',$counts);
        $this->assign('items',$items);
        return $this->fetch();
    }
}
